home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / shadez.swf / scripts / Local / Game / World / CWorld.as < prev   
Encoding:
Text File  |  2011-08-19  |  7.8 KB  |  300 lines

  1.  
  2. {
  3.    if(true)
  4.    {
  5.       CWorld = ┬º┬ºnewclass(CWorld,Sprite);
  6.    }
  7. }
  8.  
  9. package Local.Game.World
  10. {
  11.    import Local.*;
  12.    import Local.Game.*;
  13.    import Local.Game.HUD.*;
  14.    import Local.Game.Level.*;
  15.    import Local.Game.Thing.*;
  16.    import Local.Game.World.Map.*;
  17.    import Local.Game.World.Map.Cell.*;
  18.    import STC9.IO.*;
  19.    import STC9.System.CProfiler;
  20.    import flash.display.*;
  21.    import flash.events.*;
  22.    import flash.filters.*;
  23.    import flash.geom.*;
  24.    
  25.    public class CWorld extends Sprite
  26.    {
  27.        
  28.       
  29.       public var mLevel:CLevel;
  30.       
  31.       private var mInitialized:Boolean = false;
  32.       
  33.       public var mMouse:CMouse;
  34.       
  35.       public var mScrollDelta:Point;
  36.       
  37.       private var _MouseMode:String;
  38.       
  39.       public var mDrawPlane:Bitmap;
  40.       
  41.       public var mMap:CMap;
  42.       
  43.       public var mPlayer:CPeep;
  44.       
  45.       public var mLandscape:CLandscape;
  46.       
  47.       private var mDrawnThings:Array;
  48.       
  49.       public var mcDraw:MovieClip;
  50.       
  51.       public var mGame:CGame;
  52.       
  53.       public function CWorld(param1:CGame)
  54.       {
  55.          mScrollDelta = new Point(0,0);
  56.          mInitialized = false;
  57.          super();
  58.          addEventListener(Event.ADDED_TO_STAGE,Initialize);
  59.       }
  60.       
  61.       public function Dispose() : void
  62.       {
  63.          if(true)
  64.          {
  65.             RemoveMouseEvents();
  66.             if(true)
  67.             {
  68.                mMouse.Dispose();
  69.             }
  70.             mLevel.Dispose();
  71.          }
  72.       }
  73.       
  74.       private function e_MOUSE_OUT(param1:MouseEvent = null) : void
  75.       {
  76.          if(true)
  77.          {
  78.             mMouse.mScope = false;
  79.          }
  80.       }
  81.       
  82.       private function GetMousePosition() : CPosition
  83.       {
  84.          return new CPosition(mouseX + mLandscape.mDrawPosition.x,mouseY + mLandscape.mDrawPosition.y);
  85.       }
  86.       
  87.       public function get mHUD() : CHUD
  88.       {
  89.          return mGame.mHUD;
  90.       }
  91.       
  92.       public function Process() : void
  93.       {
  94.          CProfiler.StartProfile("Thing.Process");
  95.          ┬º┬ºpush(mLevel);
  96.          if(true)
  97.          {
  98.             if(┬º┬ºpop().Process != null)
  99.             {
  100.                addr26:
  101.                mLevel.Process();
  102.             }
  103.             mLandscape.Process();
  104.             mMouse.Process();
  105.             CProfiler.StopProfile("Thing.Process");
  106.             return;
  107.          }
  108.          ┬º┬ºgoto(addr26);
  109.       }
  110.       
  111.       public function Draw() : void
  112.       {
  113.          ┬º┬ºpush(mLandscape);
  114.          if(true)
  115.          {
  116.             ┬º┬ºpop().StartRender();
  117.             CProfiler.StartProfile("Landscape.Draw");
  118.             mDrawPlane.bitmapData = mLandscape.Render();
  119.             CProfiler.StopProfile("Landscape.Draw");
  120.             CThingSprite.bPlane = mDrawPlane.bitmapData;
  121.             CProfiler.StartProfile("Thing.Draw");
  122.             Draw_Things();
  123.             CProfiler.StopProfile("Thing.Draw");
  124.             ┬º┬ºpush(mLandscape);
  125.          }
  126.          ┬º┬ºpop().EndRender();
  127.       }
  128.       
  129.       public function Start() : void
  130.       {
  131.          mLevel.Start();
  132.       }
  133.       
  134.       private function e_MOUSE_MOVE(param1:MouseEvent = null) : void
  135.       {
  136.          if(true)
  137.          {
  138.             CThingSprite.mMousePosition = mMouse.mCurrentPosition = GetMousePosition();
  139.             mMouse.mLocalPosition = new CPosition(mouseX,mouseY);
  140.          }
  141.       }
  142.       
  143.       private function e_MOUSE_UP(param1:MouseEvent) : void
  144.       {
  145.          ┬º┬ºpush(mMouse);
  146.          if(true)
  147.          {
  148.             ┬º┬ºpop().mClickPosition = GetMousePosition();
  149.             ┬º┬ºpush(mMouse);
  150.          }
  151.          ┬º┬ºpop().mClick = true;
  152.       }
  153.       
  154.       private function e_MOUSE_OVER(param1:MouseEvent = null) : void
  155.       {
  156.          if(true)
  157.          {
  158.             mMouse.mScope = true;
  159.          }
  160.       }
  161.       
  162.       public function SetupMouseEvents() : void
  163.       {
  164.          if(true)
  165.          {
  166.             addEventListener(MouseEvent.MOUSE_OUT,e_MOUSE_OUT);
  167.             if(true)
  168.             {
  169.                addEventListener(MouseEvent.MOUSE_OVER,e_MOUSE_OVER);
  170.                if(true)
  171.                {
  172.                   addEventListener(MouseEvent.MOUSE_MOVE,e_MOUSE_MOVE);
  173.                   addEventListener(MouseEvent.MOUSE_UP,e_MOUSE_UP);
  174.                }
  175.                addChild(mMouse = new CMouse(this));
  176.             }
  177.             e_MOUSE_MOVE();
  178.          }
  179.       }
  180.       
  181.       public function Draw_Debug() : void
  182.       {
  183.          var _loc1_:* = undefined;
  184.          for each(_loc1_ in mDrawnThings)
  185.          {
  186.             if(true)
  187.             {
  188.                if(_loc1_.mCollide)
  189.                {
  190.                   _loc1_.mCollide.Draw(CThingSprite.bPlane,mLandscape.mDrawPosition);
  191.                }
  192.             }
  193.          }
  194.       }
  195.       
  196.       public function Draw_Things() : void
  197.       {
  198.          var _loc1_:CThingSprite = null;
  199.          if(true)
  200.          {
  201.             CProfiler.StartProfile("Thing.StackSort");
  202.          }
  203.          for each(_loc1_ in mDrawnThings)
  204.          {
  205.             if(true)
  206.             {
  207.                _loc1_.mDrawn = false;
  208.             }
  209.          }
  210.          if(true)
  211.          {
  212.             if(true)
  213.             {
  214.                mDrawnThings = new Array();
  215.                ┬º┬ºpush(0);
  216.                if(true)
  217.                {
  218.                   var _loc2_:* = ┬º┬ºpop();
  219.                   if(true)
  220.                   {
  221.                      for each(_loc1_ in mMap.GetDrawThings(mLandscape.mDrawPosition.x - CCell.mSize * 3,mLandscape.mDrawPosition.x + CThingSprite.bPlane.width + CCell.mSize * 3))
  222.                      {
  223.                         mDrawnThings.push(_loc1_);
  224.                      }
  225.                      mDrawnThings.sortOn("zDepth",Array.NUMERIC);
  226.                      CProfiler.StopProfile("Thing.StackSort");
  227.                      addr106:
  228.                      _loc2_ = 0;
  229.                   }
  230.                   for each(_loc1_ in mDrawnThings)
  231.                   {
  232.                      if(true)
  233.                      {
  234.                         _loc1_.Draw();
  235.                      }
  236.                   }
  237.                   addr131:
  238.                   return;
  239.                   addr130:
  240.                }
  241.                ┬º┬ºgoto(addr106);
  242.             }
  243.             ┬º┬ºgoto(addr131);
  244.          }
  245.          ┬º┬ºgoto(addr130);
  246.       }
  247.       
  248.       public function Initialize(param1:Event = null) : void
  249.       {
  250.          if(true)
  251.          {
  252.             removeEventListener(Event.ADDED_TO_STAGE,Initialize);
  253.             if(true)
  254.             {
  255.                mInitialized = true;
  256.                if(true)
  257.                {
  258.                   mGame = CGame(parent);
  259.                   if(true)
  260.                   {
  261.                      mLandscape = new CLandscape(this);
  262.                      if(true)
  263.                      {
  264.                         mMap = new CMap(mLandscape);
  265.                      }
  266.                      mLevel = new CLevel(this);
  267.                   }
  268.                   CThingBase.mGame = mGame;
  269.                }
  270.                addChild(mDrawPlane = new Bitmap());
  271.             }
  272.             SetupMouseEvents();
  273.          }
  274.       }
  275.       
  276.       public function Resize(param1:int, param2:int) : void
  277.       {
  278.          if(true)
  279.          {
  280.             mLandscape.Resize(param1,param2 - 106);
  281.          }
  282.       }
  283.       
  284.       public function Initialise() : void
  285.       {
  286.          CThingBase.Restart();
  287.          mDrawnThings = new Array();
  288.          mLevel.NextStage();
  289.       }
  290.       
  291.       public function RemoveMouseEvents() : void
  292.       {
  293.          removeEventListener(MouseEvent.MOUSE_OUT,e_MOUSE_OUT);
  294.          removeEventListener(MouseEvent.MOUSE_OVER,e_MOUSE_OVER);
  295.          removeEventListener(MouseEvent.MOUSE_MOVE,e_MOUSE_MOVE);
  296.          removeEventListener(MouseEvent.MOUSE_UP,e_MOUSE_UP);
  297.       }
  298.    }
  299. }
  300.